home *** CD-ROM | disk | FTP | other *** search
/ Programmers Heaven 2 / Programmers Heaven 2.iso / files / graphics / library / wgt51_r2.zip / WGT5 / EXAMPLES / WGT13.C < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-03  |  3.3 KB  |  108 lines

  1. /*
  2. ==============================================================================
  3.               WordUp Graphics Toolkit Version 5.0                     
  4.                  Demonstration Program 13                         
  5.                                           
  6.  Demonstrates mouse noclick, mousehape, msetspeed, wsetthreshhold and wbutt.  
  7.                                           
  8.  *** PROJECT ***                                                             
  9.  This program requires the file WGT5_WC.LIB to be linked.                    
  10.                                           
  11.  *** DATA FILES ***                                                          
  12.  NONE                                                                        
  13.                                WATCOM C++ VERSION 
  14. ==============================================================================
  15. */
  16.  
  17. #include <wgt5.h>
  18.  
  19. unsigned short wgtcursor[] = {
  20.     0x3ff, 0x3ff, 0x7ff, 0x3ff, 0x1ff, 0x20ff,0xf07f,0xf8ff,
  21.     0xfdff,0x1000,0x0,   0x0,   0x1,   0x1,   0x1,   0x1,
  22.     0x0,   0x7800,0x7000,0x7800,0x5c00,0xe00 ,0x700, 0x200,
  23.     0x0,   0x0,   0x45ce,0x4504,0x5564,0x5524,0x7de4,0x0     };
  24.  
  25.    /* This is the shape of the mouse cursor.  You can create
  26.       source code for these with the sprite editor. */
  27.  
  28. void main(void)
  29. {
  30.   color palette[256];
  31.   short i;
  32.   short doneflag;               /* end of loop */
  33.   short px, py, pbut;
  34.   short oldmode;
  35.   
  36.   printf ("WGT Example #13\n\n");
  37.   printf ("This program demonstrates a few of the WGT mouse commands.\n");
  38.   printf ("Follow the onscreen instructions to complete the demo.\n");
  39.   printf ("\n\nPress any key to continue.\n");
  40.   getch ();
  41.  
  42.   if ( !vgadetected () )
  43.   {
  44.     printf("Error - VGA card required for any WGT program.\n");
  45.     exit (0);
  46.   }
  47.   oldmode = wgetmode ();
  48.   vga256 ();
  49.  
  50.   for (i = 1; i < 253; i++)
  51.     wsetrgb (i, i + 30, i + 30, i, palette);  /* just something other
  52.                          than black! */
  53.   wsetrgb (253, 60, 60, 60, palette);
  54.   wsetrgb (254, 50, 50, 50, palette);
  55.   wsetrgb (255, 40, 40, 40, palette);
  56.   wsetpalette (0, 255, palette);
  57.  
  58.   wcls (0);
  59.  
  60.   wbutt (1, 1, 319, 50);
  61.   wbutt (1, 60, 319, 109);   /* Draw some 3D buttons */
  62.   wbutt (1, 189, 319, 199);
  63.  
  64.   wtextcolor (253);
  65.   wtexttransparent (TEXTFG);
  66.   wouttextxy (30, 10, NULL, "This button doesn't use noclick()");
  67.   wouttextxy (60, 70, NULL, "This button does!");
  68.   wouttextxy (100, 191, NULL, "Click here to quit");
  69.  
  70.   minit ();
  71.   msetbounds (0, 0, 319, 199);
  72.   msetspeed (20, 5);                      /* make x slow and y real fast */
  73.   msetthreshhold (10);
  74.   mouseshape (0, 0, &wgtcursor);            /* 0,0 for hotspot */
  75.  
  76.   mon ();
  77.   doneflag = 0;                           /* keep looping until flag is 1 */
  78.  
  79.   do {
  80.     px = mouse.mx;
  81.     py = mouse.my;
  82.     pbut = mouse.but;
  83.  
  84.     if (pbut != 0)                       /* Mouse button was pressed */
  85.     {
  86.       if (py < 50)                        /* Top button ? */
  87.       {
  88.     sound (500);
  89.     delay (30);
  90.     nosound ();
  91.       }
  92.       else if ((py < 109) && (py > 60))      /* Middle button ? */
  93.       {
  94.     sound (500);
  95.     delay (30);
  96.     nosound ();
  97.     noclick ();
  98.       }
  99.       else if (py > 189)
  100.     doneflag = 1;                     /* You hit the quit button */
  101.     }
  102.   } while (!doneflag);
  103.   minit (); /* Resets to arrow cursor */
  104.   mdeinit ();                   /* Deinitialize the mouse handler */
  105.  
  106.   wsetmode (oldmode);
  107. }
  108.